# Importing Data
BOSNIA<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "F1:F229")

# Checking the Imported Data
View(BOSNIA)
# Creating Time Series Data
BOSNIA_ts <- ts(BOSNIA, start=c(1998,1), end=c(2016,12), frequency=12)
# Viewing and Checking the Created Time Series Data
BOSNIA_ts
sum(is.na(BOSNIA_ts))
library(forecast)
BOSNIA_ts <- tsclean(BOSNIA_ts)
BOSNIA_ts

# Identification: Plotting the Time Series Data
plot(BOSNIA_ts)

# Estimating the appropriate model
BOSNIA_ts_model <- auto.arima(BOSNIA_ts)
BOSNIA_ts_model

# Forecasting
options(max.print=1000000)
BOSNIA_ts_forecast <- forecast (BOSNIA_ts_model, level=c(95), h=288)
plot(BOSNIA_ts_forecast)
BOSNIA_ts_forecast             

# Exporting
write.table(BOSNIA_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/BOSNIA_TSA.csv", sep=",")
